// (Financial application: calculate future investment value) Write a program that 
// reads in investment amount, annual interest rate, and number of years, 
// and displays the future investment value using the following formula:
// futureInvestmentValue =
// investmentAmount * (1 + monthlyInterestRate)numberOfYears*12
// For example, if you enter amount 1000, annual interest rate 3.25%, and number 
// of years 1, the future investment value is 1032.98.

import java.util.Scanner;

public class test221 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        
        // 提示用户输入投资金额、年利率和年数
        System.out.print("Enter investment amount: ");
        double investmentAmount = input.nextDouble();
        
        System.out.print("Enter annual interest rate in percentage: ");
        double annualInterestRate = input.nextDouble();
        
        System.out.print("Enter number of years: ");
        int years = input.nextInt();
        
        // 将年利率转换为月利率（百分比转为小数，再除以12）
        double monthlyInterestRate = annualInterestRate / 100.0 / 12.0;
        
        // 计算未来投资价值
        double futureValue = investmentAmount * 
                            Math.pow(1 + monthlyInterestRate, years * 12);
        
        // 显示结果，保留两位小数
        System.out.printf("Future value is $%.2f", futureValue);
        
        input.close();
    }
}
